#ifndef   M_Code_STYLEDTEXTCTRL_H_INCLUDED
#define   M_Code_STYLEDTEXTCTRL_H_INCLUDED

#include "wx/wxscintilla.h"
#include <wx/longlong.h>

#include <map>
#include <set>

class wxContextMenuEvent;
class wxFocusEvent;
class wxMouseEvent;
class wxPoint;

class M_Code_StyledTextCtrl : public wxScintilla {
  public:
    M_Code_StyledTextCtrl( wxWindow* pParent, int id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = 0 );
    virtual ~M_Code_StyledTextCtrl();
    void operator=( const M_Code_StyledTextCtrl& );
    wxDateTime GetLastFocusTime() const {return m_lastFocusTime;}
    wxString GetLastSelectedText() const {return m_lastSelectedText;}
    void EnableTabSmartJump( bool enable = true );
    bool IsCharacter( int style );
    bool IsString( int style );
    bool IsPreprocessor( int style );
    bool IsComment( int style );
    void CallTipCancel();
    bool IsBraceShortcutActive();
    void DoBraceCompletion( const wxChar& ch );
    bool DoSelectionBraceCompletion( const wxChar& ch );
    static std::map<int, std::set<int> > &GetCharacterLexerStyles();
    static std::map<int, std::set<int> > &GetStringLexerStyles();
    static std::map<int, std::set<int> > &GetPreprocessorLexerStyles();
    static std::map<int, std::set<int> > &GetCommentLexerStyles();
    void MakeNearbyLinesVisible( int line );
  private:
    void OnContextMenu( wxContextMenuEvent& event );
    void OnKillFocus( wxFocusEvent& event );
    void OnSetFocus( wxFocusEvent& event );
    void OnMouseMiddleDown( wxMouseEvent& event );
    void OnKeyDown( wxKeyEvent& event );
    void OnKeyUp( wxKeyEvent& event );
    void OnMouseLeftUp( wxMouseEvent& event );
    bool AllowTabSmartJump();
    void HighlightRightBrace();
    void EmulateDwellStart();
    wxWindow* m_pParent;
    wxLongLong m_lastFocusTime;
    int m_bracePosition;
    int m_lastPosition;
    bool m_tabSmartJump;
    wxString m_lastSelectedText;
    bool m_braceShortcutState;
    static std::map<int, std::set<int> > CharacterLexerStyles;
    static std::map<int, std::set<int> > StringLexerStyles;
    static std::map<int, std::set<int> > PreprocessorLexerStyles;
    static std::map<int, std::set<int> > CommentLexerStyles;

    DECLARE_EVENT_TABLE()
};

#endif
